<?php
use doumiaoduo\layer\LayerAsset;
LayerAsset::register($this);
?>
<div class="docs-main">
    <div id="search-area" class="yx-bgf7f7f7 yx-radius5 yx-function2 yx-pr0" style="margin-bottom:15px;">
        <?= \common\components\helpers\Search::textInput('goods_name', null, ['label'=>'课程名称','class' => 'search yx-width150 zx-lh24 yx-ml6']); ?>
        <?= \common\components\helpers\Search::textInput('teacher_name', null, ['label'=>'老师','class' => 'search yx-input-text zx-width150 yx-ml6']); ?>
        <?=\common\components\helpers\Search::dropDownList('is_shelve',null,[0=>'下架',1=>'上架'],['label'=>'状态','promote'=>'请选择','class'=>'search diy_select_txt']); ?>
        <?= \common\components\helpers\Search::button('搜索', ['id'=>'search-handle','class'=>"yx-search yx-radius2"]); ?>
    </div>
    <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check" data-url="<?=\common\components\helpers\Fun::url(['characteristic/index'])?>"  >
        <thead>
        <tr class="yx-bgd2f6ec">
            <th scope="name">课程</th>
            <th scope="teacherStr">老师</th>
            <th scope="cate_name">分类</th>
            <th scope="room_name">教室</th>
            <th scope="class_time">上课时间</th>
            <th scope="shelve_status">状态</th>
            <th scope="set">设置</th>
        </tr>
        </thead>
    </table>
</div>
<?=\yii\helpers\Html::hiddenInput('hidden',null,['id'=>'dosubmit'])?>
<?= $this->renderFile('@app/views/layouts/script_data.php'); ?>
<?php
$js=<<<JS
 layer.config({
        extend: ['skin/customskin/style.css']//加载您的扩展样式
    });
    $(document).on('click','a[rel=set]',function(){
        var url = $(this).data('url');
        var parent = $(this).parent();
        $.ajax({
             url:url,
             type:'get',
             dataType:'json',
             beforeSend:function(){
                layer.load(0, { shade: [0.5, '#393D49'] });
             },
             complete:function(){
              layer.close(layer.load(0, { shade: [0.5, '#393D49'] }));  
            },
            success:function(data){
                  if(data == 1){
                      parent.html('<button class="yx-btn-disabled" type="button">设置特色</button>');
                      layer.msg("设置成功！",{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
                  }else {
                      layer.msg("系统错误！",{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
                  }
            }
            
         });
    });
    $(document).on('click','#dosubmit',function(e){
         e.preventDefault();
         var url = $('#tablesaw').data('url');
         var index = parent.layer.getFrameIndex(window.name);
            parent.location.href=url;
            parent.layer.close(index);
    });
JS;
$this->registerJs($js);
?>
